package com.aaa.controller.fpa;

import com.aaa.controller.BaseController;
import com.aaa.entity.PageSortEntity;
import com.aaa.entity.Result;
import com.aaa.entity.fpa.TestPlanFpa;
import com.aaa.service.fpa.PersonalityTestPlanService;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：chenang（731712841@qq.com）
 * @date ：Created in 2022/9/1 17:26
 * @description：性格测试, 测试计划控制层 tbl_test_plan_fpa
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/testpfa")
public class PersonalityTestPlanController extends BaseController {
    @Autowired
    PersonalityTestPlanService personalityTestPlanService;
    /**
     *    分页查询
     * @param pageSortEntity
     * @param personalityTestPlanEntity
     * @return
     */
    @RequestMapping("queryPersonalityTestPlanAll.do")
    public Result queryPersonalityTestPlanAll(PageSortEntity pageSortEntity , TestPlanFpa personalityTestPlanEntity){
        Page page = personalityTestPlanService.queryPersonalityTestPlanAll(pageSortEntity, personalityTestPlanEntity);
        return success(page.getResult(),page.getTotal());
    }
    /**
     *   多行删除
     * @param id
     * @return
     */
    @RequestMapping("deletequeryPersonalityTestPlan.do")
    public Result deletequeryPersonalityTestPlan(int[] id){
        int i = personalityTestPlanService.deletequeryPersonalityTestPlan(id);
        if(i>0){
            return success("删除成功");
        }else {
            return fail("删除失败");
        }
    }
    /**
     *     修改
     * @param personalityTestPlanEntity
     * @return
     */
    @RequestMapping("updatePersonalityTestPlan.do")
    public Result  updatePersonalityTestPlan(TestPlanFpa personalityTestPlanEntity){
        int i = personalityTestPlanService.updatePersonalityTestPlan(personalityTestPlanEntity);
        if(i>0){
            return success("修改成功");
        }else {
            return fail("修改失败");
        }
    }
    /**
     * 添加
     */
    @RequestMapping("addPersonalityTestPlan.do")
    public Result addPersonalityTestPlan(TestPlanFpa testPlanFpa){
        TestPlanFpa testPlanFpa1 = personalityTestPlanService.addPersonalityTestPlan(testPlanFpa);
        return success(testPlanFpa1);
    }
    /**
     * 测试题目唯一性校验
     */
    @RequestMapping("repetitionName.do")
    public Result repetitionName(TestPlanFpa testPlanFpa){
        int i = personalityTestPlanService.repetitionName(testPlanFpa);
        if(i>0){
            return success("测试名以重复");
        }else {
            return fail("");
        }
    }
}
